<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <title>会员注册 - <?php echo config('website.site_name')?></title>
        <link rel="stylesheet" type="text/css" href="__LIBS__/layui/css/layui.css" />
        <link rel="stylesheet" type="text/css" href="__USER__/css/login.css" />
    </head>
    <body>
        <div class="m-login-bg">
            <div class="m-login">
                <h3>会员注册-<?php echo config('website.site_name')?></h3>
                <div class="m-login-warp">
                    <form class="layui-form" action="{:url('user/index/register')}" method="post">
                        <div class="layui-form-item">
                            <input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="请输入账号" class="layui-input">
                        </div>
                        <div class="layui-form-item">
                            <input type="text" id="mobile" name="mobile" lay-verify="required" autocomplete="off" placeholder="请输入手机号码" class="layui-input">
                        </div>
                        <!--div class="layui-form-item">
                            <div class="layui-inline">
                                <input id="code1" type="text" name="code" class="layui-input" autocomplete="off" placeholder="短信验证码"/>
                            </div>
                            <div class="layui-inline">
                                <input id="btnSendCode1" type="button" class="verifyImg" value="获取验证码" onClick="sendMessage1()"/>
                            </div>
                            
                        </div-->
                        <div class="layui-form-item">
                            <input type="password" name="password" lay-verify="required" autocomplete="off" placeholder="请输入密码" class="layui-input">
                        </div>
                        <div class="layui-form-item">
                            <input type="password" name="password_confirm" lay-verify="required" autocomplete="off" placeholder="再次输入密码" class="layui-input">
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <input type="text" name="captcha" lay-verify="required" autocomplete="off" placeholder="验证码" class="layui-input">
                            </div>
                            <div class="layui-inline">
                                <img class="verifyImg" src="{:url('user/index/captcha')}" onclick="this.src='{:url('user/index/captcha')}?rand='+Math.random()" />
                            </div>
                        </div>
                        <div class="layui-form-item m-login-btn">
                            <div class="layui-inline">
                                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submit">注册</button>
                            </div>
                        </div>
                    </form>
                        
                </div>
                <p class="copyright"><?php echo config('website.site_copyright')?></p>
            </div>
        </div>

        <script>
        layui.use(['layer', 'form', 'jquery'], function(){
            var layer = layui.layer,
                form  = layui.form,
                $     = layui.jquery;
            form.on('submit(register)', function(data) {
                var index = layer.msg('登录中，请稍候', {
                    icon: 16,
                    time: false,
                    shade: 0.3
                });
                $.ajax({
                    url: data.form.action,
                    type: data.form.method,
                    dataType: 'json',
                    data: $(data.form).serialize(),
                    success: function(result) {
                        if (result.code === 1) {
                            location.href = result.url;
                        } else {
                            $('.captcha img').attr('src', '{:url("user/index/captcha")}?rand='+Math.random());
                            layer.close(index);
                            layer.msg(result.msg);
                        }
                    },
                    error: function (xhr, state, errorThrown) {
                        layer.close(index);
                        layer.msg(state + '：' + errorThrown);
                    }
                });
                return false;
            });
        });
        </script>
        <script type="text/javascript">
			var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;//手机号正则 
			var count = 60; //间隔函数，1秒执行
			var InterValObj1; //timer变量，控制时间
			var curCount1;//当前剩余秒数
			/*第一*/
			function sendMessage1() {
				curCount1 = count;		 		 
				var phone = $.trim($('#mobile').val());
				if (!phoneReg.test(phone)) {
					alert(" 请输入有效的手机号码"); 
					return false;
				}
                                $.ajax({
                                    type: "POST",      //data 传送数据类型。post 传递
                                    dataType: 'json',  // 返回数据的数据类型json
                                    url: "/user/index/captcha_sms",  // yii 控制器/方法
                                    cache: false,      
                                    data: {mobile: phone},  //传送的数据
                                    error:function(){
                                       alert("数据传输错误");
                                    },success: function (data) {
                                       if(window.console){
                                           console.log(data);
                                       }else{
                                           console.log(data);
                                       }
                                    }
                                });      
                                
				//设置button效果，开始计时
				$("#btnSendCode1").attr("disabled", "true");
				$("#btnSendCode1").val( + curCount1 + "秒再获取");
				InterValObj1 = window.setInterval(SetRemainTime1, 1000); //启动计时器，1秒执行一次
				//向后台发送处理数据
				
			}
			function SetRemainTime1() {
				if (curCount1 == 0) {                
					window.clearInterval(InterValObj1);//停止计时器
					$("#btnSendCode1").removeAttr("disabled");//启用按钮
					$("#btnSendCode1").val("重新发送");
				}
				else {
					curCount1--;
					$("#btnSendCode1").val( + curCount1 + "秒再获取");
				}
			} 
			
			/*提交*/
			function binding(){
				alert(1)
			}
		</script>
        <script src="__LIBS__/layui/layui.all.js"></script>
<script src="__JS__/jquery.min.js"></script>
<script src="__JS__/layui.base.js"></script>
<script src="/static/js/multiSelect.js"></script>
<script src="/static/js/common.js"></script>


    </body>
</html>